package com.amc.jms;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;

public class AsyncConsumer {

	public AsyncConsumer() {

	}
//	public static void main(String[] args) {
//		
//	}
	public void receive() {
		ConnectionFactory cf = new ActiveMQConnectionFactory(
				"failover://tcp://localhost:61616");
		Connection conn;
		try {
			conn = cf.createConnection();
			Session session = conn.createSession(false,
					Session.AUTO_ACKNOWLEDGE);
			Destination queue = new ActiveMQQueue("kate-queue");
			MessageConsumer consumer = session.createConsumer(queue);

			conn.start();

			consumer.setMessageListener(new ConsumerMessageListener());

		} catch (JMSException e1) {
			e1.printStackTrace();
		}
	}
}
